
import java.util.Vector;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Yongke
 */
public class ChatList {

        private Vector<Chat> ListChat;

    public ChatList()
    {
        ListChat = new Vector<Chat>();
    }

    public Vector<Chat> getListChat(){return ListChat;}

    public void addChat(Chat C)
    {
        ListChat.add(C);}

    public Vector<Chat> getChat(String username, String username2)
    {
        Vector<Chat> getC = new Vector<Chat>();
        for (int i = 0; i < ListChat.size(); i++)
        {
            if ((ListChat.elementAt(i).getSender().equals(username) && ListChat.elementAt(i).getReceiver().equals(username2))
                    || (ListChat.elementAt(i).getSender().equals(username2) && ListChat.elementAt(i).getReceiver().equals(username)))
            {getC.add(ListChat.elementAt(i));}
        }
        return getC;
    }

    public Vector<Chat> getChat(String roomname)
    {
        Vector<Chat> getR = new Vector<Chat>();
        for (int i = 0; i < ListChat.size(); i ++)
        {
            if (ListChat.elementAt(i).getRoom().equals(roomname))
            {getR.add(ListChat.elementAt(i));}
        }
        return getR;
    }
}
